package com.twq.controller;

import com.twq.pojo.User;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello(){
        return "hello";
    }


    @GetMapping("/hello2")
    @ApiOperation(value = "查询该子账号的用户类型", notes = "查询该子账号的用户类型 ")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "西门", required = true, dataType = "String", paramType = "query"),
    })
    public String hello2(String username) {
        return "hello " + username;
    }

    /**
     * 只要我们的接口中，返回值中存在实体类, 他就会扫描到Swagger中
     */
    @ApiOperation("post测试登录")
    @PostMapping(value = "/user")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "username", value = "西门", required = true, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "password", value = "1111", required = true, dataType = "String", paramType = "query"),
//    })
    public User user(User user) {
        return user;
    }

    @ApiOperation("Post测试类")
    @PostMapping(value = "/post")
    public User postt(@ApiParam("用户名") User user) {
        return user;
    }

}
